<template>
  <view class="content">
    <view class="text-area">
      <text class="title">{{ title }}</text>
    </view>
    <view>
      <button @click="goToAdmin">管理员页面</button>
    </view>
    <!-- 使用组件进行权限控制 -->
    <Permission :value="['admin']">
      <view>管理员才能看到的内容</view>
    </Permission>
    <Permission :value="['admin', 'counter']" :any="true">
      <view>有一个权限即可看到的内容</view>
    </Permission>
  </view>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { testApi } from '@/api/user';

definePage({
  style: {
    "navigationBarTitleText": "首页"
  }
})

const title = ref('Hello')

// // 使用组合函数进行权限控制
// const hasAdminPermission = usePermission('admin');
// const hasAnyPermission = usePermission(['admin', 'counter'], 'any');

const res = testApi();
console.log('index page', res);

const goToAdmin = () => {
  // setTimeout(() => {
    
  // }, 1000);

  uni.navigateTo({
    url: '/pages-sub/admin/index'
  })
}
</script>

<style>
.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.logo {
  height: 200rpx;
  width: 200rpx;
  margin-top: 200rpx;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 50rpx;
}

.text-area {
  display: flex;
  justify-content: center;
}

.title {
  font-size: 36rpx;
  color: #8f8f94;
}
</style>
